window.onload = function() {
    // 创建一个vue实例
    new Vue({
        el: '#root',
        data: {
            name: 'jack',
            text: "",
            obj: { name: 'xxx' },
            lists: [
                { name: '手机', state: '0' },
                { name: '电脑', state: '0' },
                { name: '化妆品', state: '1' },
                { name: 'psp', state: '1' },
                { name: '大哥大', state: '2' },
            ]
        },
        methods: {
            add: function(name) {
                if (name) {
                    this.lists.unshift({ name: name, state: '0' })
                    this.text = '';
                }
            },
            del: function(index) {
                this.lists.splice(index, 1)
            }

        },
        filters: {
            statefilter: function(type) {
                switch (type) {
                    case "0":
                        return '未采购';
                    case "1":
                        return '采购中';
                    case "2":
                        return '已采购';
                    default:
                        return '';
                }
            }
        },
    })
}